<?php
$secret = 'de27690e21f911e**********e198b20'; // Signature Secret
$app_id = 'bw_de27*******11e';
$fields = array( 'app_id' => $app_id,
                'device_number' => '200****001',
				'lock_address' => '0101',
				'use_type' => 'S',
				'timestamps' => time());
ksort($fields);
echo $fields;
$sign = hash('SHA512', http_build_query($fields) . $secret);
echo http_build_query($fields) . $secret;
echo '-----------iot openbox create sign--------------\n';
echo $sign;
echo '-----------iot openbox api test--------------\n';
echo http_build_query($fields);
$curl = curl_init();
echo '-----------iot openbox teststart--------------\n';
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://dgndev.bestwond.com/api/iot/open/box/?sign='.$sign,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>json_encode($fields),
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
   ),
));
echo '-----------$curl--------------\n';
echo $curl;
$response = curl_exec($curl);

curl_close($curl);
echo $response;
echo '----------$response-------------\n';
?>